//Linux C plus plus file
/************************************************************************
*
*
*       			FileName:select_model.cpp
*
*         			Author.wzj
*
*       			Email:345517039@qq.com
*
*      	    		Create:2017-06-22 23:41:51
*
*      		    	Description:-
*
*
*************************************************************************/
#include "select_model.h"


/**
 * @brief 
 */
SelectMode::SelectMode(){
	
}


/**
 * @brief 
 */
SelectMode::~SelectMode(){

}


/**
 * @brief 
 *
 * @return 
 */
int SelectMode::init(){
	this->ioname="select";
	FD_ZERO(&(this->ctx.readset));
	FD_ZERO(&(this->ctx.writeset));
	this->ctx.maxfd = 0;
	this->stopflag = 0;
	this->ctx.tv.tv_sec =0;
	this->ctx.tv.tv_usec = 1000;
	return 1;
}

int SelectMode::addEvent(int fd)
{

	return RET::SUCCESS;
}


/**
 * @brief 
 *
 * @param arg
 *
 * @return 
 */
int SelectMode::addEvent(void *arg){
	int * eventfd = (int *)arg; //这边的强转要注意点;
	ctx.maxfd = (ctx.maxfd < *eventfd) ? (*eventfd): ctx.maxfd;
	FD_SET(*eventfd,&(this->ctx.readset));
	FD_SET(*eventfd,&(this->ctx.writeset));
	return 1;
}



/**
 * @brief 
 *
 * @param arg
 *
 * @return 
 */
int SelectMode::delEvent(void *arg){
	int *eventfd = (int *)arg;
	FD_CLR(*eventfd, &(this->ctx.readset));
	FD_CLR(*eventfd, &(this->ctx.writeset));
	return 1;
}



/**
 * @brief 
 *
 * @param type
 *
 * @return 
 */
int SelectMode::waitForEvent(int type){


}



